import React, {Component} from 'react';
import {Form, Input, Radio, Select} from 'antd';

const FormItem = Form.Item;

class UserInfoForm extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        const {getFieldDecorator} = this.props.form;
        let defaultValue = this.props.defaultValue;
        return (
            <Form layout="vertical">
                <FormItem label="用户姓名">
                    {getFieldDecorator('name', {
                        rules: [{
                            required: true,
                            message: 'Please input the title of collection!'
                        }],
                        initialValue: defaultValue.name
                    })(
                        <Input id="name" name="name"/>
                    )}
                </FormItem>
                <FormItem label="用户名称">
                    {getFieldDecorator('userName', {
                        rules: [{
                            required: true,
                            message: 'Please input the title of collection!'
                        }],
                        initialValue: defaultValue.userName
                    })(
                        <Input id="userName" name="userName"/>
                    )}
                </FormItem>
                <FormItem label="用户密码">
                    {getFieldDecorator('password', {
                        rules: [{
                            required: true,
                            message: 'Please input the title of collection!'

                        }],
                        initialValue: defaultValue.password
                    })(
                        <Input id="password" name="password"/>
                    )}
                </FormItem>
                <FormItem label="联系方式">
                    {getFieldDecorator('telephone', {
                        rules: [{
                            required: true,
                            message: 'Please input the title of collection!'
                        }],
                        initialValue: defaultValue.telephone
                    })(
                        <Input id="telephone" name="telephone"/>
                    )}
                </FormItem>
                <FormItem label="性别">
                    {getFieldDecorator('sex', {
                        rules: [{
                            required: true,
                            message: 'Please input the title of collection!'
                        }],
                        initialValue: defaultValue.sex
                    })(
                        <Select>
                            <Option value='1'>男</Option>
                            <Option value='0'>女</Option>
                        </Select>
                    )}
                </FormItem>
                <FormItem label="年龄">
                    {getFieldDecorator('age', {
                        rules: [{
                            required: true,
                            message: 'Please input the title of collection!'
                        }],
                        initialValue: defaultValue.age
                    })(
                        <Input id="age" name="age"/>
                    )}
                </FormItem>
            </Form>
        );
    }
}

let userInfoForm = Form.create()(UserInfoForm);
export default userInfoForm;